package com.yugao.fintech.antelope.infra.module.file.listener;

import com.yugao.fintech.antelope.dynamic.config.core.event.ConfigDeleteEvent;
import com.yugao.fintech.antelope.infra.module.file.manager.FileManager;
import com.yugao.fintech.antelope.base.model.enums.ConfigDefineEnum;
import com.yugao.fintech.antelope.base.model.module.tenant.TenantContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class LocalConfigDeleteListener {

    @EventListener(ConfigDeleteEvent.class)
    public void defaultDelete(ConfigDeleteEvent event) {
        Object source = event.getSource();
        if (!ConfigDefineEnum.STORAGE.name().equals(source)) {
            return;
        }
        Long tenantId = TenantContextHolder.get().getTenantId();
        FileManager.storageParamCache.remove(String.valueOf(tenantId));
        log.info("delete storage channel param ===> tenantId: {}", tenantId);
    }
}
